package com.dykj.fireFighting.web.maintenance;

import com.dykj.fireFighting.api.base.maintenance.dto.RepairRecordDto;
import com.dykj.fireFighting.api.base.maintenance.dto.UrgentMaintenanceDto;
import com.dykj.fireFighting.api.base.maintenance.service.IRepairRecordService;
import com.dykj.fireFighting.api.base.maintenance.service.IUrgentMaintenanceService;
import com.dykj.fireFighting.api.base.maintenance.vo.RepairRecordVo;
import com.dykj.fireFighting.api.base.maintenance.vo.UrgentMaintenanceVo;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 紧急维保记录接口
 *
 * @Author JacksonTu
 * @Date 2021-07-28 08:38:40
 */
@Slf4j
@Api(value = "紧急维保记录接口", tags = {"紧急维保记录接口"})
@RestController
@RequestMapping("/urgentMaintenance")
public class UrgentMaintenanceController {

    @DubboReference
    private IUrgentMaintenanceService urgentMaintenanceService;
    @DubboReference
    private IRepairRecordService repairRecordService;


    /**
     * 紧急维保记录列表
     *
     * @return
     */
    @AutoLog(value = "紧急维保记录-分页列表查询")
    @ApiOperation(value = "紧急维保记录分页列表", notes = "紧急维保记录分页列表")
    @GetMapping("/list")
    public CommonResult<PageVo<UrgentMaintenanceVo>> queryUrgentMaintenanceList(UrgentMaintenanceDto urgentMaintenanceDto) {
        if (ShiroUtil.getUser().getEnterpriseId() != null) {
            urgentMaintenanceDto.setSociologyDept(ShiroUtil.getUser().getEnterpriseId().toString());
        }
        PageVo<UrgentMaintenanceVo> page = urgentMaintenanceService.queryUrgentMaintenanceList(urgentMaintenanceDto);
        return CommonResult.success(page);
    }

    /**
     * 获取紧急维保维修记录信息
     *
     * @param id
     * @return
     */
    @AutoLog(value = "获取紧急维保维修记录信息")
    @ApiOperation(value = "获取紧急维保维修记录信息", notes = "获取紧急维保维修记录信息")
    @ApiImplicitParam(paramType = "path", name = "id", value = "主键ID", dataType = "String", required = true)
    @GetMapping("/info/{id}")
    public CommonResult<UrgentMaintenanceVo> getInfoById(@PathVariable("id") String id) {
        UrgentMaintenanceVo urgentMaintenanceVo = urgentMaintenanceService.getInfoById(id);
        return CommonResult.success(urgentMaintenanceVo);
    }

    /**
     * 维修记录表列表
     *
     * @return
     */
    @AutoLog(value = "维修记录表-分页列表查询")
    @ApiOperation(value = "维修记录表分页列表", notes = "维修记录表分页列表")
    @GetMapping("/repairRecord/list")
    public CommonResult<PageVo<RepairRecordVo>> queryRepairRecordList(RepairRecordDto repairRecordDto) {
        //repairRecordDto.setMaintenanceDept(ShiroUtil.getUser().getEnterpriseId().toString());
        PageVo<RepairRecordVo> page = repairRecordService.queryRepairRecordList(repairRecordDto);
        return CommonResult.success(page);
    }
}
